import Vue from 'vue';
import VueRouter from 'vue-router';
import { LoadingBar } from 'iview';
import routes from './routes';

Vue.use(VueRouter);

// 路由配置
const router = new VueRouter({
  base: __dirname,
  routes: routes
});

router.beforeEach((to, from, next) => {
  LoadingBar.start();

  next();
});

router.afterEach(() => {
  LoadingBar.finish();
  window.scrollTo(0, 0);
});

export default router;
